package cn.ssh.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import cn.ssh.dao.CommonDao;

@Repository("commonDao")
public class CommonDaoHibImpl extends HibernateDaoSupport implements CommonDao {

	public CommonDaoHibImpl() {
		// TODO Auto-generated constructor stub
	}
	@Autowired
	public CommonDaoHibImpl(@Qualifier("sessionFactory")SessionFactory sessionFactory) {
		// TODO Auto-generated constructor stub
		this.setSessionFactory(sessionFactory);
	}
	@Override
	public Object get(Class clazz, Serializable id) {
		// TODO Auto-generated method stub
		Object ret = super.getHibernateTemplate().get(clazz, id);
		return ret;
	}

	@Override
	public Serializable add(Object o) {
		// TODO Auto-generated method stub
		Serializable ret = super.getHibernateTemplate().save(o);
		return ret;
	}

	@Override
	public void del(Class clazz, Serializable id) {
		super.getHibernateTemplate().delete(this.get(clazz, id));

	}

	@Override
	public void update(Object o) {
		// TODO Auto-generated method stub
		super.getHibernateTemplate().update(o);

	}

	@Override
	public List search(String hql) {
		// TODO Auto-generated method stub
		List ret = super.getHibernateTemplate().find(hql);
		return ret;
	}

}
